# coding: utf-8
from datetime import datetime
from uuid import uuid4
from enum import Enum

from sqlalchemy import Column, Integer, TIMESTAMP, Index, Float, CHAR
from sqlalchemy import String, text, Enum as SqlEnum
from sqlalchemy.dialects.mysql import TEXT, VARCHAR
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from typing import Optional

from app.db.model.base import Base


# def get_class_by_tablename(tablename: str):
#     """通过表名获取对应的 ORM 类"""
#     # 获取所有已注册的类
#     registry = Base.registry
#
#     for mapper in registry.mappers:
#         class_ = mapper.class_
#         if hasattr(class_, '__tablename__') and class_.__tablename__ == tablename:
#             return class_
#     raise LookupError(f"表 {tablename} 未注册")


class Building(Base):
    __tablename__ = 'building'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    bname: Mapped[str] = mapped_column(String)
    type: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_

    @classmethod
    def allow_fields(cls, user_role=None):
        """定义前端可访问字段"""
        base_fields = [col.name for col in cls.__table__.columns]
        return base_fields


class ClassAnalysis(Base):
    __tablename__ = 'class_analysis'

    object_id: Mapped[str] = mapped_column(String, primary_key=True)
    subject: Mapped[str] = mapped_column(String)
    class_number: Mapped[str] = mapped_column(String)
    date: Mapped[str] = mapped_column(String)
    teacher: Mapped[str] = mapped_column(String)
    class_: Mapped[str] = mapped_column(String, name='class')
    classroom: Mapped[str] = mapped_column(String)
    ai_grading: Mapped[str] = mapped_column(String)
    class_grading: Mapped[str] = mapped_column(String)
    teaching_type: Mapped[str] = mapped_column(String)
    attendance_rate: Mapped[str] = mapped_column(String)
    front_row_seating_ratio: Mapped[str] = mapped_column(String)
    concentration_exponent: Mapped[str] = mapped_column(String)
    active_exponent: Mapped[str] = mapped_column(String)
    passive_exponent: Mapped[str] = mapped_column(String)
    net_teaching_time: Mapped[str] = mapped_column(String)
    lesson_category: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors1(Base):
    __tablename__ = 'floors1'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors2(Base):
    __tablename__ = 'floors2'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors3(Base):
    __tablename__ = 'floors3'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors4(Base):
    __tablename__ = 'floors4'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors5(Base):
    __tablename__ = 'floors5'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors6(Base):
    __tablename__ = 'floors6'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors7(Base):
    __tablename__ = 'floors7'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors8(Base):
    __tablename__ = 'floors8'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class Floors9(Base):
    __tablename__ = 'floors9'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    building: Mapped[str] = mapped_column(String)
    bname: Mapped[str] = mapped_column(String)
    floor: Mapped[str] = mapped_column(String)
    elv: Mapped[str] = mapped_column(String)
    high: Mapped[str] = mapped_column(String)
    length: Mapped[str] = mapped_column(String)
    wide: Mapped[str] = mapped_column(String)
    area: Mapped[str] = mapped_column(String)
    x: Mapped[str] = mapped_column(String)
    y: Mapped[str] = mapped_column(String)
    info: Mapped[str] = mapped_column(String)
    a1: Mapped[str] = mapped_column(String)
    geometry: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class GraduationInfo2020(Base):
    __tablename__ = 'graduation_info_2020'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String, primary_key=True)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    is_or_not_graduation: Mapped[str] = mapped_column(String)
    graduate_destination: Mapped[str] = mapped_column(String)
    graduate_destination_category: Mapped[str] = mapped_column(String)
    graduate_school_or_workplace: Mapped[str] = mapped_column(String)
    graduate_profession_or_job_position: Mapped[str] = mapped_column(String)
    graduate_category: Mapped[str] = mapped_column(String)
    major_matches_job: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class GraduationInfo2021(Base):
    __tablename__ = 'graduation_info_2021'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String, primary_key=True)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    is_or_not_graduation: Mapped[str] = mapped_column(String)
    graduate_destination: Mapped[str] = mapped_column(String)
    graduate_destination_category: Mapped[str] = mapped_column(String)
    graduate_school_or_workplace: Mapped[str] = mapped_column(String)
    graduate_profession_or_job_position: Mapped[str] = mapped_column(String)
    graduate_category: Mapped[str] = mapped_column(String)
    major_matches_job: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitInfo2020(Base):
    __tablename__ = 'recruit_info_2020'

    name: Mapped[str] = mapped_column(String)
    birthday: Mapped[str] = mapped_column(String)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String)
    junior_high_school: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String)
    admission_ticket_number: Mapped[str] = mapped_column(String, primary_key=True)
    subject_score: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String)
    converted_score: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitInfo2021(Base):
    __tablename__ = 'recruit_info_2021'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String)
    junior_high_school: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String)
    admission_ticket_number: Mapped[str] = mapped_column(String, primary_key=True)
    subject_score: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String)
    converted_score: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitInfo2022(Base):
    __tablename__ = 'recruit_info_2022'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String, primary_key=True)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String)
    junior_high_school: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String)
    converted_score: Mapped[str] = mapped_column(String)
    chinese_score: Mapped[str] = mapped_column(String)
    converted_chinese_score: Mapped[str] = mapped_column(String)
    math_score: Mapped[str] = mapped_column(String)
    converted_math_score: Mapped[str] = mapped_column(String)
    english_score: Mapped[str] = mapped_column(String)
    converted_english_score: Mapped[str] = mapped_column(String)
    chinese_math_english_score: Mapped[str] = mapped_column(String)
    avg_score: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitInfo2023(Base):
    __tablename__ = 'recruit_info_2023'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String, primary_key=True)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    professional_department: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String)
    junior_high_school: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String)
    converted_score: Mapped[str] = mapped_column(String)
    chinese_score: Mapped[str] = mapped_column(String)
    converted_chinese_score: Mapped[str] = mapped_column(String)
    math_score: Mapped[str] = mapped_column(String)
    converted_math_score: Mapped[str] = mapped_column(String)
    english_score: Mapped[str] = mapped_column(String)
    converted_english_score: Mapped[str] = mapped_column(String)
    chinese_math_english_score: Mapped[str] = mapped_column(String)
    avg_score: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitInfo2024(Base):
    __tablename__ = 'recruit_info_2024'

    name: Mapped[str] = mapped_column(String, primary_key=True)
    birthday: Mapped[str] = mapped_column(String, primary_key=True)
    gender: Mapped[str] = mapped_column(String)
    campus: Mapped[str] = mapped_column(String)
    professional_department: Mapped[str] = mapped_column(String)
    profession: Mapped[str] = mapped_column(String)
    class_category: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String)
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String)
    junior_high_school: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String)
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String)
    converted_score: Mapped[str] = mapped_column(String)
    chinese_score: Mapped[str] = mapped_column(String)
    converted_chinese_score: Mapped[str] = mapped_column(String)
    math_score: Mapped[str] = mapped_column(String)
    converted_math_score: Mapped[str] = mapped_column(String)
    english_score: Mapped[str] = mapped_column(String)
    converted_english_score: Mapped[str] = mapped_column(String)
    chinese_math_english_score: Mapped[str] = mapped_column(String)
    avg_score: Mapped[str] = mapped_column(String)

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitStudentInfo2020(Base):
    __tablename__ = 'recruit_student_info_2020'

    exam_id: Mapped[str] = mapped_column(String(255), primary_key=True)
    student_name: Mapped[str] = mapped_column(String(255))
    profession: Mapped[str] = mapped_column(String(255))
    class_category: Mapped[str] = mapped_column(String(255))
    hometown: Mapped[str] = mapped_column(String(255))
    gender: Mapped[str] = mapped_column(String(255))
    card_id: Mapped[str] = mapped_column(String(255))
    nation: Mapped[str] = mapped_column(String(255))
    political_appearance: Mapped[str] = mapped_column(String(255))
    student_category: Mapped[str] = mapped_column(String(255))
    junior_high_school_name: Mapped[str] = mapped_column(String(255))
    class_name: Mapped[str] = mapped_column(String(255))
    physical_education: Mapped[str] = mapped_column(String(255))
    chinese: Mapped[str] = mapped_column(String(255))
    math: Mapped[str] = mapped_column(String(255))
    english: Mapped[str] = mapped_column(String(255))
    politics: Mapped[str] = mapped_column(String(255))
    physics: Mapped[str] = mapped_column(String(255))
    chemistry: Mapped[str] = mapped_column(String(255))
    total_score: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class RecruitStudentInfo2023(Base):
    __tablename__ = 'recruit_student_info_2023'

    name: Mapped[str] = mapped_column(String(255), primary_key=True)
    birthday: Mapped[str] = mapped_column(String(255), primary_key=True)
    gender: Mapped[str] = mapped_column(String(255))
    grade: Mapped[str] = mapped_column(String(255))
    campus: Mapped[str] = mapped_column(String(255))
    professional_department: Mapped[str] = mapped_column(String(255))
    profession: Mapped[str] = mapped_column(String(255))
    class_category: Mapped[str] = mapped_column(String(255))
    class_: Mapped[str] = mapped_column(String(255), name='class')
    junior_high_school_students_source_province: Mapped[str] = mapped_column(String(255))
    junior_high_school_students_source_city: Mapped[str] = mapped_column(String(255))
    junior_high_school_students_source_districts: Mapped[str] = mapped_column(String(255))
    junior_high_school: Mapped[str] = mapped_column(String(255))
    high_school_entrance_examination_city: Mapped[str] = mapped_column(String(255))
    high_school_entrance_examination_score: Mapped[str] = mapped_column(String(255))
    converted_score: Mapped[str] = mapped_column(String(255))
    chinese_score: Mapped[str] = mapped_column(String(255))
    converted_chinese_score: Mapped[str] = mapped_column(String(255))
    math_score: Mapped[str] = mapped_column(String(255))
    converted_math_score: Mapped[str] = mapped_column(String(255))
    english_score: Mapped[str] = mapped_column(String(255))
    converted_english_score: Mapped[str] = mapped_column(String(255))
    chinese_math_english_score: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class ScoreInfo(Base):
    __tablename__ = 'score_info'

    年份: Mapped[str] = mapped_column(String(255), primary_key=True)
    总分: Mapped[str] = mapped_column(String(255))
    市平均分: Mapped[str] = mapped_column(String(255))
    普高录取线: Mapped[str] = mapped_column(String(255))
    录取平均分: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class ScoreInfo20215(Base):
    __tablename__ = 'score_info_2021_5'

    name: Mapped[str] = mapped_column(String(255))
    id: Mapped[str] = mapped_column(String(255), primary_key=True)
    class_id: Mapped[str] = mapped_column(String(255))
    class_: Mapped[str] = mapped_column(String(255), name='class')
    f101: Mapped[str] = mapped_column(String(255))
    f102: Mapped[str] = mapped_column(String(255))
    f103: Mapped[str] = mapped_column(String(255))
    f104: Mapped[str] = mapped_column(String(255))
    f105: Mapped[str] = mapped_column(String(255))
    f106: Mapped[str] = mapped_column(String(255))
    f107: Mapped[str] = mapped_column(String(255))
    f108: Mapped[str] = mapped_column(String(255))
    f109: Mapped[str] = mapped_column(String(255))
    f110: Mapped[str] = mapped_column(String(255))
    f201: Mapped[str] = mapped_column(String(255))
    f202: Mapped[str] = mapped_column(String(255))
    f203: Mapped[str] = mapped_column(String(255))
    f204: Mapped[str] = mapped_column(String(255))
    f205: Mapped[str] = mapped_column(String(255))
    f206: Mapped[str] = mapped_column(String(255))
    f207: Mapped[str] = mapped_column(String(255))
    f208: Mapped[str] = mapped_column(String(255))
    f209: Mapped[str] = mapped_column(String(255))
    f210: Mapped[str] = mapped_column(String(255))
    f301: Mapped[str] = mapped_column(String(255))
    f302: Mapped[str] = mapped_column(String(255))
    f303: Mapped[str] = mapped_column(String(255))
    f304: Mapped[str] = mapped_column(String(255))
    f305: Mapped[str] = mapped_column(String(255))
    f306: Mapped[str] = mapped_column(String(255))
    f307: Mapped[str] = mapped_column(String(255))
    f308: Mapped[str] = mapped_column(String(255))
    f309: Mapped[str] = mapped_column(String(255))
    f401: Mapped[str] = mapped_column(String(255))
    f402: Mapped[str] = mapped_column(String(255))
    f403: Mapped[str] = mapped_column(String(255))
    f404: Mapped[str] = mapped_column(String(255))
    f405: Mapped[str] = mapped_column(String(255))
    f406: Mapped[str] = mapped_column(String(255))
    f407: Mapped[str] = mapped_column(String(255))
    f408: Mapped[str] = mapped_column(String(255))
    f409: Mapped[str] = mapped_column(String(255))
    f410: Mapped[str] = mapped_column(String(255))
    f411: Mapped[str] = mapped_column(String(255))
    f501: Mapped[str] = mapped_column(String(255))
    f601: Mapped[str] = mapped_column(String(255))
    f602: Mapped[str] = mapped_column(String(255))
    f603: Mapped[str] = mapped_column(String(255))
    f604: Mapped[str] = mapped_column(String(255))
    f605: Mapped[str] = mapped_column(String(255))
    f606: Mapped[str] = mapped_column(String(255))
    f607: Mapped[str] = mapped_column(String(255))
    f608: Mapped[str] = mapped_column(String(255))
    f609: Mapped[str] = mapped_column(String(255))
    f1_avg: Mapped[str] = mapped_column(String(255))
    f2_avg: Mapped[str] = mapped_column(String(255))
    f3_avg: Mapped[str] = mapped_column(String(255))
    f4_avg: Mapped[str] = mapped_column(String(255))
    f5_avg: Mapped[str] = mapped_column(String(255))
    f6_avg: Mapped[str] = mapped_column(String(255))
    avg_score: Mapped[str] = mapped_column(String(255))
    chinese_math_english_avg_score: Mapped[str] = mapped_column(String(255))
    zhuanYeKe_score: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class ScoreInfo20216(Base):
    __tablename__ = 'score_info_2021_6'

    name: Mapped[str] = mapped_column(String(255))
    id: Mapped[str] = mapped_column(String(255), primary_key=True)
    class_id: Mapped[str] = mapped_column(String(255))
    class_: Mapped[str] = mapped_column(String(255), name='class')
    f101: Mapped[str] = mapped_column(String(255))
    f102: Mapped[str] = mapped_column(String(255))
    f103: Mapped[str] = mapped_column(String(255))
    f104: Mapped[str] = mapped_column(String(255))
    f105: Mapped[str] = mapped_column(String(255))
    f106: Mapped[str] = mapped_column(String(255))
    f107: Mapped[str] = mapped_column(String(255))
    f108: Mapped[str] = mapped_column(String(255))
    f109: Mapped[str] = mapped_column(String(255))
    f110: Mapped[str] = mapped_column(String(255))
    f201: Mapped[str] = mapped_column(String(255))
    f202: Mapped[str] = mapped_column(String(255))
    f203: Mapped[str] = mapped_column(String(255))
    f204: Mapped[str] = mapped_column(String(255))
    f205: Mapped[str] = mapped_column(String(255))
    f206: Mapped[str] = mapped_column(String(255))
    f207: Mapped[str] = mapped_column(String(255))
    f208: Mapped[str] = mapped_column(String(255))
    f209: Mapped[str] = mapped_column(String(255))
    f210: Mapped[str] = mapped_column(String(255))
    f301: Mapped[str] = mapped_column(String(255))
    f302: Mapped[str] = mapped_column(String(255))
    f303: Mapped[str] = mapped_column(String(255))
    f304: Mapped[str] = mapped_column(String(255))
    f305: Mapped[str] = mapped_column(String(255))
    f306: Mapped[str] = mapped_column(String(255))
    f307: Mapped[str] = mapped_column(String(255))
    f308: Mapped[str] = mapped_column(String(255))
    f309: Mapped[str] = mapped_column(String(255))
    f310: Mapped[str] = mapped_column(String(255))
    f401: Mapped[str] = mapped_column(String(255))
    f402: Mapped[str] = mapped_column(String(255))
    f403: Mapped[str] = mapped_column(String(255))
    f404: Mapped[str] = mapped_column(String(255))
    f405: Mapped[str] = mapped_column(String(255))
    f406: Mapped[str] = mapped_column(String(255))
    f407: Mapped[str] = mapped_column(String(255))
    f408: Mapped[str] = mapped_column(String(255))
    f409: Mapped[str] = mapped_column(String(255))
    f410: Mapped[str] = mapped_column(String(255))
    f411: Mapped[str] = mapped_column(String(255))
    f501: Mapped[str] = mapped_column(String(255))
    f502: Mapped[str] = mapped_column(String(255))
    f503: Mapped[str] = mapped_column(String(255))
    f504: Mapped[str] = mapped_column(String(255))
    f505: Mapped[str] = mapped_column(String(255))
    f506: Mapped[str] = mapped_column(String(255))
    f507: Mapped[str] = mapped_column(String(255))
    f508: Mapped[str] = mapped_column(String(255))
    f509: Mapped[str] = mapped_column(String(255))
    f601: Mapped[str] = mapped_column(String(255))
    f1_avg: Mapped[str] = mapped_column(String(255))
    f2_avg: Mapped[str] = mapped_column(String(255))
    f3_avg: Mapped[str] = mapped_column(String(255))
    f4_avg: Mapped[str] = mapped_column(String(255))
    f5_avg: Mapped[str] = mapped_column(String(255))
    f6_avg: Mapped[str] = mapped_column(String(255))
    avg_score: Mapped[str] = mapped_column(String(255))
    chinese_math_english_avg_score: Mapped[str] = mapped_column(String(255))
    zhuanYeKe_score: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class SmartClassroomReport(Base):
    __tablename__ = 'smart_classroom_report'

    object_id: Mapped[str] = mapped_column(String(255), primary_key=True)
    subject: Mapped[str] = mapped_column(String(255))
    class_number: Mapped[str] = mapped_column(String(255))
    date: Mapped[str] = mapped_column(String(255))
    teacher: Mapped[str] = mapped_column(String(255))
    class_: Mapped[str] = mapped_column(String(255), name='class')
    classroom: Mapped[str] = mapped_column(String(255))
    ai_grading: Mapped[str] = mapped_column(String(255))
    class_grading: Mapped[str] = mapped_column(String(255))
    teaching_type: Mapped[str] = mapped_column(String(255))
    attendance_rate: Mapped[str] = mapped_column(String(255))
    front_row_seating_ratio: Mapped[str] = mapped_column(String(255))
    concentration_exponent: Mapped[str] = mapped_column(String(255))
    active_exponent: Mapped[str] = mapped_column(String(255))
    passive_exponent: Mapped[str] = mapped_column(String(255))
    net_teaching_time: Mapped[str] = mapped_column(String(255))

    def to_dict(self):
        dict_ = {}
        for c in self.__table__.columns:
            attr_name = c.name if hasattr(self, c.name) else c.name + "_"
            dict_[c.name] = getattr(self, attr_name)
        return dict_


class TempLog(Base):
    __tablename__ = 'temp_log'
    __table_args__ = {
        'comment': 'This table logs job execution details, including job time, operator, job description, and entry time.'}

    id = Column(Integer, primary_key=True, comment='唯一标识符')
    job_time = Column(VARCHAR(255), nullable=False, comment='作业执行的时间')
    operator = Column(VARCHAR(255), nullable=False, comment='执行作业的人员')
    job_description = Column(TEXT, comment='作业的具体内容')
    entry_time = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"), comment='记录填写的时间（自动获取当前时间）')


class WorkLog(Base):
    __tablename__ = 'work_log'
    __table_args__ = {
        'comment': 'This table logs job execution details, including job time, operator, job description, and entry time.'}

    id = Column(Integer, primary_key=True, comment='唯一标识符')
    work_time = Column(TIMESTAMP, nullable=False, comment='作业执行的时间')
    operator = Column(VARCHAR(255), nullable=False, comment='执行作业的人员')
    work_title = Column(VARCHAR(255))
    work_description = Column(TEXT, comment='作业的具体内容')
    entry_time = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                        comment='记录填写的时间（自动获取当前时间）')


# class UserInfo(Base):
#     __tablename__ = "user_info"
#     __table_args__ = {
#         'comment': '用户信息表'
#     }
#
#     id: Mapped[str] = mapped_column(
#         CHAR(36),
#         primary_key=True,
#         comment="主键",
#         default=lambda: str(uuid4())
#     )
#     user_id: Mapped[str] = mapped_column(
#         String(50),
#         nullable=False,
#         comment="ID"
#     )
#     password: Mapped[str] = mapped_column(
#         String(255),
#         nullable=False,
#         comment="密码"
#     )
#     name: Mapped[Optional[str]] = mapped_column(
#         String(50),
#         nullable=True,
#         comment="姓名"
#     )
#     role: Mapped[Optional[str]] = mapped_column(
#         String(255),
#         nullable=True,
#         comment="角色"
#     )


# class User(Base):
#     __tablename__ = 'user'
#     __table_args__ = (
#         Index('idx_username', 'username'),
#         Index('idx_created_at', 'created_at'),
#         {'mysql_charset': 'utf8mb4', 'mysql_collate': 'utf8mb4_unicode_ci'}
#     )
#
#     id: Mapped[str] = mapped_column(
#         String(36),
#         primary_key=True,
#         default=lambda: str(uuid4()),
#         comment='用户UUID'
#     )
#     username: Mapped[str] = mapped_column(
#         String(50),
#         unique=True,
#         nullable=False,
#         comment='用户名'
#     )
#     password: Mapped[str] = mapped_column(
#         String(255),
#         nullable=False,
#         comment='密码哈希值'
#     )
#     role: Mapped[str] = mapped_column(
#         String(20),
#         nullable=False,
#         default='guest',
#         comment='用户角色'
#     )

class UserRole(str, Enum):
    DEPARTMENT_HEAD = 'department_head'
    GROUP_LEADER = 'group_leader'
    TEACHER = 'teacher'
    ADMIN = 'admin'
    GUEST = 'guest'
    DEV_OPERATOR = 'dev_operator'


class Users(Base):
    __tablename__ = 'users'
    __table_args__ = (
        Index('department_id', 'department_id'),
        Index('tgp_id', 'tgp_id'),
        {
            'comment': '用户信息表',
            'mysql_engine': 'InnoDB',
            'mysql_charset': 'utf8mb4',
            'mysql_collate': 'utf8mb4_0900_ai_ci'
        }
    )

    user_id: Mapped[str] = mapped_column(
        String(36),
        primary_key=True,
        default=lambda: str(uuid4()),
        comment='用户UUID'
    )
    teacher_id: Mapped[str] = mapped_column(
        String(50),
        unique=True,
        nullable=False,
        comment='教师ID'
    )
    password: Mapped[str] = mapped_column(
        String(255),
        nullable=False,
        comment='密码'
    )
    name: Mapped[Optional[str]] = mapped_column(
        String(50),
        nullable=True,
        comment='姓名'
    )
    department_id: Mapped[Optional[str]] = mapped_column(
        String(50),
        nullable=True,
        comment='部门ID'
    )
    tgp_id: Mapped[Optional[str]] = mapped_column(
        String(50),
        nullable=True,
        comment='教研组ID'
    )
    role: Mapped[UserRole] = mapped_column(
        SqlEnum(UserRole, native_enum=True, length=20, values_callable=lambda enum: [e.value for e in enum]),
        nullable=False,
        comment='用户角色'
    )
    created_at: Mapped[datetime] = mapped_column(
        TIMESTAMP(timezone=True),
        server_default=text('CURRENT_TIMESTAMP'),
        nullable=False,
        comment='创建时间'
    )
    updated_at: Mapped[datetime] = mapped_column(
        TIMESTAMP(timezone=True),
        server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
        nullable=False,
        comment='更新时间'
    )


class RefreshToken(Base):
    """
        Refresh Token存储表
        字段说明:
        - jti: JWT唯一标识(主键)
        - user_id: 关联的用户ID
        - token_hash: token的加密哈希值
        - expires: 过期时间
        - revoked: 是否已主动撤销
        - client_fp: 客户端指纹（防止token盗用）
        """
    __tablename__ = 'refresh_tokens'
    __table_args__ = (
        Index('idx_user_id', 'user_id'),
        Index('idx_composite', 'user_id', 'expires', 'revoked'),
        {'mysql_charset': 'utf8mb4', 'mysql_collate': 'utf8mb4_unicode_ci'}
    )

    jti: Mapped[str] = mapped_column(
        String(36),
        primary_key=True,
        default=lambda: str(uuid4()),
        comment='JWT唯一标识'
    )
    user_id: Mapped[str] = mapped_column(
        String(36),
        nullable=False,
        comment='关联用户UUID'
    )
    token_hash: Mapped[str] = mapped_column(
        String(255),
        nullable=False,
        comment='令牌哈希值'
    )
    expires: Mapped[datetime] = mapped_column(
        nullable=False,
        comment='过期时间'
    )
    revoked: Mapped[int] = mapped_column(
        default=0,
        nullable=False,
        comment='是否撤销(0:否 1:是)'
    )
    client_fp: Mapped[str] = mapped_column(
        String(255),
        nullable=False,
        comment='客户端指纹哈希'
    )
    created_at: Mapped[datetime] = mapped_column(
        server_default=text('CURRENT_TIMESTAMP'),
        nullable=False
    )
    updated_at: Mapped[datetime] = mapped_column(
        server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
        nullable=False
    )

    # user: Mapped[Users] = relationship(
    #     back_populates='refresh_tokens',
    #     single_parent=True
    # )

    def is_valid(self):
        """验证token有效性：未撤销且未过期"""
        return not self.revoked and datetime.utcnow() < self.expires


class AccessLogs(Base):
    __tablename__ = "access_logs"
    __table_args__ = {"comment": "网络访问日志表"}

    id: Mapped[int] = mapped_column(
        Integer,
        primary_key=True,
        autoincrement=True,
        comment="主键ID"
    )
    student_id: Mapped[str] = mapped_column(String(255), nullable=True)
    name: Mapped[str] = mapped_column(String(255), nullable=True)
    grade: Mapped[str] = mapped_column(String(255), nullable=True)
    student_class: Mapped[str] = mapped_column(String(255), nullable=True)
    source_ip: Mapped[str] = mapped_column(String(255), nullable=True)
    terminal_type: Mapped[str] = mapped_column(String(255), nullable=True)
    target_ip: Mapped[str] = mapped_column(String(255), nullable=True)
    application_type: Mapped[str] = mapped_column(String(255), nullable=True)
    specific_application: Mapped[str] = mapped_column(String(255), nullable=True)
    access_control: Mapped[str] = mapped_column(String(255), nullable=True)
    access_time: Mapped[str] = mapped_column(String(255), nullable=True)
    access_domain: Mapped[str] = mapped_column(String(255), nullable=True)
    url_address: Mapped[str] = mapped_column(String(1000), nullable=True)
    dns: Mapped[str] = mapped_column(String(255), nullable=True)
    terminal_details: Mapped[str] = mapped_column(String(255), nullable=True)
    source_port: Mapped[str] = mapped_column(String(255), nullable=True)
    service_port: Mapped[str] = mapped_column(String(255), nullable=True)
    protocol: Mapped[str] = mapped_column(String(255), nullable=True)
    mac: Mapped[str] = mapped_column(String(255), nullable=True)
    application_category: Mapped[str] = mapped_column(String(255), nullable=True)
    application_rule: Mapped[str] = mapped_column(String(255), nullable=True)
    connections_per_minute: Mapped[str] = mapped_column(String(255), nullable=True)
    policy: Mapped[str] = mapped_column(String(255), nullable=True)
    description: Mapped[str] = mapped_column(String(255), nullable=True)
    details: Mapped[str] = mapped_column(String(255), nullable=True)
    title: Mapped[str] = mapped_column(String(255), nullable=True)
    account: Mapped[str] = mapped_column(String(255), nullable=True)
    nm_id_type: Mapped[str] = mapped_column(String(255), nullable=True)
    serv_id: Mapped[str] = mapped_column(String(255), nullable=True)
    app_name: Mapped[str] = mapped_column(String(255), nullable=True)
    app_id: Mapped[str] = mapped_column(String(255), nullable=True)
    chat_action: Mapped[str] = mapped_column(String(255), nullable=True)
    receiver_account: Mapped[str] = mapped_column(String(255), nullable=True)
    url_type: Mapped[str] = mapped_column(String(255), nullable=True)
    longitude: Mapped[str] = mapped_column(String(255), nullable=True)
    latitude: Mapped[str] = mapped_column(String(255), nullable=True)


class TC20(Base):
    """20年体能测试表"""
    __tablename__ = "20_tc"

    name: Mapped[str] = mapped_column(String(255), primary_key=True)
    year: Mapped[int] = mapped_column(Integer, primary_key=True)
    class_num: Mapped[Optional[int]] = mapped_column(Integer)
    class_: Mapped[Optional[str]] = mapped_column("class_", String(255))
    total: Mapped[Optional[int]] = mapped_column(Integer)
    total_level: Mapped[Optional[str]] = mapped_column(String(255))


class CJ22(Base):
    """22年成绩表"""
    __tablename__ = "22_cj"

    name: Mapped[str] = mapped_column(String(255), primary_key=True)
    class_: Mapped[str] = mapped_column("class_", String(255), primary_key=True)
    cj_2201_ty: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2202_ty: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2301_ty: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2302_ty: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2201_avg: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2202_avg: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2301_avg: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2302_avg: Mapped[Optional[int]] = mapped_column(Integer)
    cj_2201_ty_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2202_ty_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2301_ty_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2302_ty_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2201_avg_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2202_avg_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2301_avg_level: Mapped[Optional[str]] = mapped_column(String(255))
    cj_2302_avg_level: Mapped[Optional[str]] = mapped_column(String(255))


class TC22(Base):
    """22年体能测试明细表"""
    __tablename__ = "22_tc"

    class_: Mapped[str] = mapped_column("class_", String(255), primary_key=True)
    name: Mapped[str] = mapped_column(String(255), primary_key=True)
    gender: Mapped[Optional[str]] = mapped_column(String(255))
    height: Mapped[Optional[int]] = mapped_column(Integer)
    weight: Mapped[Optional[int]] = mapped_column(Integer)
    weight_score: Mapped[Optional[int]] = mapped_column(Integer)
    weight_grade: Mapped[Optional[str]] = mapped_column(String(255))
    pulmonary: Mapped[Optional[int]] = mapped_column(Integer)
    pulmonary_score: Mapped[Optional[int]] = mapped_column(Integer)
    pulmonary_level: Mapped[Optional[str]] = mapped_column(String(255))
    dash: Mapped[Optional[float]] = mapped_column(Float)
    dash_score: Mapped[Optional[int]] = mapped_column(Integer)
    dash_level: Mapped[Optional[str]] = mapped_column(String(255))
    jump: Mapped[Optional[int]] = mapped_column(Integer)
    jump_score: Mapped[Optional[int]] = mapped_column(Integer)
    jump_level: Mapped[Optional[str]] = mapped_column(String(255))
    sit: Mapped[Optional[int]] = mapped_column(Integer)
    sit_score: Mapped[Optional[int]] = mapped_column(Integer)
    sit_level: Mapped[Optional[str]] = mapped_column(String(255))
    kilometer: Mapped[Optional[str]] = mapped_column(String(255))
    kilometer_score: Mapped[Optional[int]] = mapped_column(Integer)
    kilometer_level: Mapped[Optional[str]] = mapped_column(String(255))
    core: Mapped[Optional[int]] = mapped_column(Integer)
    core_score: Mapped[Optional[int]] = mapped_column(Integer)
    core_level: Mapped[Optional[str]] = mapped_column(String(255))
    total: Mapped[Optional[int]] = mapped_column(Integer)
    total_level: Mapped[Optional[str]] = mapped_column(String(255))


class XL22(Base):
    """22年心理量表数据表"""
    __tablename__ = "22_xl"

    class_: Mapped[str] = mapped_column("class_", String(255), primary_key=True)
    name: Mapped[str] = mapped_column(String(255), primary_key=True)
    gender: Mapped[Optional[str]] = mapped_column(String(255))
    obsessive_compulsive: Mapped[Optional[float]] = mapped_column(Float)
    paranoid: Mapped[Optional[float]] = mapped_column(Float)
    hostility: Mapped[Optional[float]] = mapped_column(Float)
    interpersonal_sensitivity: Mapped[Optional[float]] = mapped_column(Float)
    depression: Mapped[Optional[float]] = mapped_column(Float)
    anxiety: Mapped[Optional[float]] = mapped_column(Float)
    academic_stress: Mapped[Optional[float]] = mapped_column(Float)
    maladaptation: Mapped[Optional[float]] = mapped_column(Float)
    emotional_instability: Mapped[Optional[float]] = mapped_column(Float)
    psychological_imbalance: Mapped[Optional[float]] = mapped_column(Float)
    total: Mapped[Optional[float]] = mapped_column(Float)
    obsessive_compulsive_level: Mapped[Optional[str]] = mapped_column(String(255))
    paranoid_level: Mapped[Optional[str]] = mapped_column(String(255))
    hostility_level: Mapped[Optional[str]] = mapped_column(String(255))
    interpersonal_sensitivity_level: Mapped[Optional[str]] = mapped_column(String(255))
    depression_level: Mapped[Optional[str]] = mapped_column(String(255))
    anxiety_level: Mapped[Optional[str]] = mapped_column(String(255))
    academic_stress_level: Mapped[Optional[str]] = mapped_column(String(255))
    maladaptation_level: Mapped[Optional[str]] = mapped_column(String(255))
    emotional_instability_level: Mapped[Optional[str]] = mapped_column(String(255))
    psychological_imbalance_level: Mapped[Optional[str]] = mapped_column(String(255))
    overall_result_level: Mapped[Optional[str]] = mapped_column(String(255))
    suicidal_thoughts: Mapped[Optional[int]] = mapped_column(Integer)
    result_warning: Mapped[Optional[str]] = mapped_column(String(255))
    interpersonal: Mapped[Optional[int]] = mapped_column(Integer)
    academic_stress_2: Mapped[Optional[int]] = mapped_column(Integer)
    punishment: Mapped[Optional[int]] = mapped_column(Integer)
    loss: Mapped[Optional[int]] = mapped_column(Integer)
    health_adaptation: Mapped[Optional[int]] = mapped_column(Integer)
    total_2: Mapped[Optional[int]] = mapped_column(Integer)
    interpersonal_level: Mapped[Optional[str]] = mapped_column(String(255))
    academic_stress_level_2: Mapped[Optional[str]] = mapped_column(String(255))
    punishment_level: Mapped[Optional[str]] = mapped_column(String(255))
    loss_level: Mapped[Optional[str]] = mapped_column(String(255))
    health_adaptation_level: Mapped[Optional[str]] = mapped_column(String(255))
    overall_level: Mapped[Optional[str]] = mapped_column(String(255))
    result_warning_2: Mapped[Optional[str]] = mapped_column(String(255))
